package com.example.administrator.x2picturetransliteration.Util;

import android.content.Context;
import android.graphics.Color;

import com.zyao89.view.zloading.ZLoadingDialog;

import static com.zyao89.view.zloading.Z_TYPE.SINGLE_CIRCLE;

/**
 * 加载等待框
 */
public class LoadingDialogUtil {

    private static LoadingDialogUtil sWaitingDialog;

    private ZLoadingDialog mZLoadingDialog;

    private LoadingDialogUtil(Context context){
        mZLoadingDialog = new ZLoadingDialog(context);
        mZLoadingDialog.setLoadingBuilder(SINGLE_CIRCLE)
                .setCanceledOnTouchOutside(false)
                .setCancelable(false)
                .setLoadingColor(Color.GRAY)
                .setHintText("等待中...");
    }

    public static LoadingDialogUtil getInstance(Context context){
        if (sWaitingDialog == null) {
            sWaitingDialog = new LoadingDialogUtil(context);
        }
        return sWaitingDialog;
    }

    public void show(){
        mZLoadingDialog.show();
    }

    public void dismiss(){
        mZLoadingDialog.dismiss();
        sWaitingDialog = null;
    }
}
